#ifndef MESH_H
#define MESH_H

#include <QObject>
#include <QVector3D>
#include <QVector2D>
#include <qstring.h>
#include<QOpenGLFunctions>
#include<QOpenGLShaderProgram>
#include<QOpenGLVertexArrayObject>
#include<QOpenGLBuffer>
#include<QVector>
#include <QOpenGLTexture>

#define MAX_BONE_INFLUENCE 4

struct Vertex
{
    // position
    QVector3D Position;
    // normal
    QVector3D Normal;
    // texCoords
    QVector2D TexCoords;
    // tangent
    QVector3D Tangent;
    // bitangent
    QVector3D Bitangent;
    //bone indexes which will influence this vertex
    int m_BoneIDs[MAX_BONE_INFLUENCE];
    //weights from each bone
    float m_Weights[MAX_BONE_INFLUENCE];
};

struct Texture {
    unsigned int id;
    QString type;
    QString path;
};

class Mesh : public QObject, protected QOpenGLFunctions
{
    Q_OBJECT
public:
    QVector<Vertex>       vertices;
    QVector<unsigned int> indices;
    QVector<Texture> textures;
    QOpenGLVertexArrayObject VAO;
    QOpenGLBuffer EBO;
    QOpenGLTexture *texture0=NULL, *texture1=NULL,*texture2=NULL;
public:
    Mesh(QVector<Vertex> vertices,QVector<unsigned int> indices,QVector<Texture> textures);
    Mesh();
    void Draw(QOpenGLShaderProgram &shader);
    ~Mesh();
private:
    QOpenGLBuffer VBO;
private:
    void setupMesh();

};

#endif // MESH_H
